package com.wll.store.common.result;

import lombok.Data;

@Data
public class Result<T> {
    /**
     * 状态码
     */
    private Integer code;

    /**
     * 信息描述
     */
    private String msg;

    /**
     * 业务数据
     */
    private T data;

    /**
     * 返回成功
     *
     * @param code
     * @param msg
     * @return
     */
    public com.wll.store.common.result.Result<T> success(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
        return this;
    }

    public com.wll.store.common.result.Result<T> success(String msg) {
        return success(200, msg);
    }

    public com.wll.store.common.result.Result<T> success() {
        return success("操作成功");
    }

    public com.wll.store.common.result.Result<T> put(T data) {
        this.data = data;
        return this;
    }

    public com.wll.store.common.result.Result<T> error(Integer code, String msg) {
        return success(code, msg);
    }

    public com.wll.store.common.result.Result<T> error(String msg) {
        return error(500, msg);
    }

    public com.wll.store.common.result.Result<T> error() {
        return error("操作失败！");
    }
}
